<script type="text/javascript">
	Yutil.useLoadingMessage();
	Yutil.en.enhance();
</script>

<fieldset >
	<legend>创建用户</legend>
	<form id="person_form" action="personCreate.do">
		<table align="left" border="1px"  class="form">
			<tr>
				<th><font>用户名</font></th>
				<td>
					<input type="text" id="userid" name="userid" class="required"/>
				</td>
			</tr>
			<tr>
				<th><font>密&nbsp;&nbsp;码</font></th>
				<td>
					<input style="width:100%" type="password" id="password" name="password" class="required"/>
				</td>
			</tr>
			<tr>
				<th><font>创建类型</font></th>
				<td>
					<select id="personType" class="required" name="personType">
						<%
							List accessGroups = (List) AccessGroupService.$.getGroups(); 
							for(int i = 0; i < accessGroups.size(); i++) {
						%>
	                   <option><%= accessGroups.get(i) %></option>
						<%
							}
						 %>
	               </select>
				</td>
			</tr>
			<tr>	
				<td colspan="2">
					<input class='button' type="button" value="添加" onclick="addUser(this);">
					<input class='button' type="button" value="取消" onclick="actionPage('la_person_list.jsp')">
				</td>
			</tr>
		</table>
	</form>
</fieldset>
<div id="add_Result">
</div>
<script type="text/javascript">
	var JForm = Class.create();       
	Object.extend(JForm.prototype, {           
		validate : function(DOMTREE){
			var userid = $('userid_add').value;
			var uiRegExp = new RegExp("^[a-z]*", "i")
			if(!uiRegExp.test(userid)) {
				alert('userid is invalid');
				return false;
			}
						
			//myRegExp.exec('a'),  return the result array
			
			return true;
	    }
	});

	formValidate = function(DOMTREE) {
		var validator = new JForm();
		return validator.validate(DOMTREE);
	}
	
	addUser = function(btn) {
		var person_form = document.getElementById('person_form');
		//must add the '/' 
		var url = "/" + "<%= LocalContants.PROJECT_NAME %>" + "/personCreate.do";// + person_form.serialize();
		//31/01/2010 by Jian
		//here warning
		//to fix IE bug
		//with Form.serialize api 
		//and chinese code decoding
		var pars = encodeURI(Form.serialize(person_form)); 
		if(Yform.validateAllOnSubmit(btn)) {
				var myAjax = new Ajax.Updater("right",url,{method:'post',parameters: pars, evalScripts:true});
		}	
	}
</script>

<%@ page import="java.util.*" %>
<%@ page import="com.esms.struts.service.*" %>
<%@ page language="java" contentType="text/html; charset=utf-8" %>